package com.tsxy.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tsxy.entity.RoleMenu;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface RoleMenuMapper extends BaseMapper<RoleMenu> {

    @Insert({
            "<script>",
            "insert into sys_role_menu (role_id,menu_id)",
            "values",
            "<foreach item ='item' index ='index' collection='menuids' separator=','> ",
            "(#{roleId},#{item})",
            "</foreach>",
            "</script>"
    })
    void insertAll(@Param("roleId") Integer roleId, @Param("menuids") List<Integer> menuids);

    @Delete({"delete from sys_role_menu where role_id = #{roleId}"})
    void deleteByRoleId(@Param("roleId") Integer roleId);

    @Select({"select menu_id from sys_role_menu where role_id = #{roleId}"})
    List<Integer> getByRoleId(@Param("roleId") Integer roleId);
}
